﻿@inherits LayoutComponentBase
@inject GlobalConfig GlobalConfig
@inject IMasaStackConfig MasaStackConfig

<SLayout Logo="https://cdn.masastack.com/stack/images/logo/MASAStack/logo-h-en.png"
         MiniLogo="https://cdn.masastack.com/stack/images/logo/MASAStack/logo.png"
         IsShowEnvironmentSwitch
         WhiteUris="_whiteUrlRoutes">
    @Body
</SLayout>

@code {
    [Inject]
    public IPopupService PopupService { get; set; } = default!;

    [Inject]
    public TscCaller ApiCaller { get; set; }

    [Inject]
    public NavigationManager NavigationManager { get; set; }

    // [Inject]
    // public IHostEnvironment HostEnvironment { get; set; }

    Task OnError(Exception exception)
    {
        PopupService.EnqueueSnackbarAsync(exception.Message, AlertTypes.Error);
        return Task.CompletedTask;
    }

    private readonly List<string> _whiteUrlRoutes = new()
    {
        "apm/*",
        "log/*",
        "trace/*",
        // for instrument like serviceList,endpointList,instanceList  jump to child instrument
        //"dashboard/*",
        //"teamDetail/*"
    };

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        // if (StorageConst.Current != null) return;
        // var setting = await ApiCaller.SettingService.GetStorage();
        // if (setting == null)
        //     throw new InvalidDataException("Storage setting is null");
        // if (setting.IsClickhouse)
        //     StorageConst.Init(new ClickhouseStorageConst());
        // else if (setting.IsElasticsearch)
        //     StorageConst.Init(new ElasticsearchStorageConst());
        // StateHasChanged();
        //NavigationManager.NavigateTo(ApmComponentBase.CurrentUrl, true);
    }
}